#include <iostream>
#include <unistd.h>
#include <ctime>
using namespace std;

typedef void (*work_t)();
typedef void (*task_t)();

void Conectsql()
{
    cout << "Conectsql" << endl;
}
void task2()
{
    cout << "ConnectCilent" << endl;
}
void task3()
{
    cout << "doing" << endl;
}

task_t tasks[3] = {Conectsql, task2, task3};
uint32_t Nexttask()
{
    return rand() % 3;
}

void worker()
{
    while (true)
    {
        uint32_t command_code = 0;
        ssize_t n = read(0, &command_code, sizeof(command_code));
        if (n == sizeof(command_code))
        {
            if (command_code > 3)
                continue;
            tasks[command_code](); // 执行
        }
        else if(n==0)
        {
            cout<<"close"<<endl;
            break;
        }
        sleep(1);
    }
}
